#pragma once
#include <iostream>
#include <unordered_map>
#include <vector>
#include <string>
#include <cstdio>
#include <functional>
#include <unistd.h>
using namespace std;

typedef function<void()> func;

vector<func> cmdset;
unordered_map<uint32_t, string> desc;

void ReadMySQL(){
    printf("sub process[%d]: 执行访问数据库任务\n\n", getpid());
}

void AnalyzeURL(){
    printf("sub process[%d]: 执行URL解析任务\n\n", getpid());
}

void Encrypt(){
    printf("sub process[%d]: 执行加密任务\n\n", getpid());
}

void Save(){
    printf("sub process[%d]: 执行数据保存任务\n\n", getpid());
}

void LoadHandler(){
    uint32_t cmdid = 0;
    cmdset.push_back(ReadMySQL);
    desc.emplace(cmdid++, "ReadMySQL: 读取数据库");
    cmdset.push_back(AnalyzeURL);
    desc.emplace(cmdid++, "AnalyzeURL: URL解析");
    cmdset.push_back(Encrypt);
    desc.emplace(cmdid++, "Encrypt: 加密计算");
    cmdset.push_back(Save);
    desc.emplace(cmdid++, "Save: 数据保存");
}

void ShowHandler(){
    for(const auto& iter : desc)
    {
        printf("cmdid: %d cmddesc: %s\n", iter.first, iter.second.c_str());
    }
}